package com.zigong.app.ui.activities;

import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.ruihang.generalibrary.ui.widget.CustomFontTextView;
import com.zigong.app.R;
import com.zigong.app.base.BaseActivity;
import com.zigong.app.ui.utils.TitleUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 关于
 */
public class AboutActivity extends BaseActivity {
    @BindView(R.id.about_current_version)
    protected CustomFontTextView current_version;
    @BindView(R.id.title_red_base)
    protected RelativeLayout titleLayout;
    @BindView(R.id.title_top_back)
    protected ImageView backImg;

    private String versioncode;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        new TitleUtils(this).setBackVisible(true).setLogo(false);
        titleLayout.setBackgroundColor(getResources().getColor(R.color.white));
        backImg.setImageResource(R.mipmap.icon_login_return_gray);
        PackageManager pm = getPackageManager();
        PackageInfo pi = null;
        try {
            pi = pm.getPackageInfo(getPackageName(), 0);
            versioncode = pi.versionName;
            current_version.setText(getString(R.string.about_current_version)+" V" + versioncode);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }


    }

    @Override
    protected void initInject() {
        setContentView(R.layout.activity_about);
        ButterKnife.bind(this);
    }
    @OnClick({R.id.user_agreement,R.id.user_privacy})
    protected void OnClick(View view) {
        if (view.getId() == R.id.user_agreement) {
            Intent intent = new Intent(this, UserAgreementActivity.class);
            intent.putExtra(UserAgreementActivity.RULE_TYPE,0);
            startActivity(intent);
        }else if (view.getId() == R.id.user_privacy) {
            Intent intent = new Intent(this, UserAgreementActivity.class);
            intent.putExtra(UserAgreementActivity.RULE_TYPE,1);
            startActivity(intent);
        }
    }

}
